<?php

if(!defined('IN_DISCUZ')) {

	exit('Access Denied');

}
if(empty($_GET['hzw_fromurl']) || empty($_GET['hzw_fid']))
{
	echo 'no';
	exit;
}
if(!isset($_G['cache']['plugin'])){

	loadcache('plugin');
}
$args=$_G['cache']['plugin']['csdn123com_kuaibao']['hzw_useuid'];
if(strpos($args,',')===false)
{
	$argsArr=array($args);
} else {
	$argsArr=explode(',',$args);
}
if(in_array($_G['uid'],$argsArr))
{	
	require './source/plugin/csdn123com_kuaibao/common.fun.php';	
	$uidstr = getRndUid();
	$fromurl = urldecode($_GET['hzw_fromurl']);
	$fromurl = preg_replace('/\?.+/','',$fromurl);
	$fid=$_GET['hzw_fid'];
	$typeid=$_GET['hzw_typeid'];
	if (strpos($fromurl,'kuaibao.qq.com') === false) {

		echo 'no1';
		exit;

	}
	$fromurl = daddslashes($fromurl);
	$chk=DB::fetch_first("SELECT ID,tid FROM " . DB::table('csdn123kuaibao_news') . " WHERE fromurl='" . $fromurl . "'  LIMIT 1");
	if(count($chk)>0 && $chk['tid']>0)
	{
		echo $chk['tid'];
		exit;
	}
	if(count($chk)==0)
	{
		$threadValue=array();
		$threadValue['uidstr']=daddslashes($uidstr);
		$threadValue['fid']=daddslashes($fid);
		$threadValue['typeid']=daddslashes($typeid);
		$threadValue['fromurl']=daddslashes($fromurl);
		$ID=DB::insert('csdn123kuaibao_news',$threadValue,true);		
		
	} else {
		
		$ID=$chk["ID"];
		
	}
	require_once './source/function/function_forum.php';
	$recode=send_thread($ID);
	if($recode=='ok')
	{
		$chk=DB::fetch_first("SELECT tid FROM " . DB::table('csdn123kuaibao_news') . " WHERE ID=" . intval($ID));
		if($chk['tid']>0)
		{
			echo $chk['tid'];
		} else {
			echo "no2";
		}
	}
	
}
	
	
	